package control.connector;

import java.awt.Color;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import sun.security.x509.AVA;

public class Taxa {
	private enum Status{available,occupied,enroute,offline,pause};
	private int taxaid;
	private Color status;
	private float latitude;
	private float longtitude;
	private int driverid; //will not be used at this time
	private HashMap<Status, Color> statusMap;
	private Set<TaxaObserver> observers;

	public Taxa(int taxaid){
		this.taxaid = taxaid;
		latitude = 0;
		longtitude = 0;
		statusMap = new HashMap<Status, Color>();
		statusMap.put(Status.available, Color.GREEN);
		statusMap.put(Status.occupied, Color.RED);
		statusMap.put(Status.enroute, Color.ORANGE);
		statusMap.put(Status.offline, Color.BLACK);
		statusMap.put(Status.pause, Color.BLUE);
		status = statusMap.get(Status.offline);
		
		observers = new HashSet<TaxaObserver>();
	}

	public Color getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = statusMap.get(Status.valueOf(status));
	}

	public float getLatitude() {
		return latitude;
	}

	public void setLatitude(float latitude) {
		this.latitude = latitude;
	}

	public float getLongtitude() {
		return longtitude;
	}

	public void setLongtitude(float longtitude) {
		this.longtitude = longtitude;
	}

	public int getTaxaid() {
		return taxaid;
	}

	public int getDriverid() {
		return driverid;
	}
	
	public void addObserver(TaxaObserver observer){
		observers.add(observer);
	}
	
	public void notifyObservers(){
		for(TaxaObserver observer: observers){
			observer.updateTaxis();
		}
	}
}
